package com.tool_stdy.concurrent;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by yan_li on 2016/1/24.
 */
public class CountDownLatchTest implements Runnable {
    static final CountDownLatch end = new CountDownLatch(10);
    @Override
    public void run() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"--> Check");
        end.countDown();
    }

    public static void main(String[] args) throws InterruptedException {
        CountDownLatchTest test = new CountDownLatchTest();
        ExecutorService exec = Executors.newFixedThreadPool(10);
        for(int i=0;i<10;i++){
            exec.submit(test);
        }
        end.await();
        System.out.println("dd+++++++++++++++++++++++++++++++++++++++++++++");
    }
}
